package teacher.action.student;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import teacher.bean.Students;
import teacher.bean.Teacher;
import teacher.page.Page;
import teacher.page.PageUtil;
import teacher.service.student;

public class searchStu extends ActionSupport{
	private static final long serialVersionUID = 1L;
	List<Students> stus=new ArrayList<Students>();
	private int currentPage;
	private String stuName;
	String suc;
	
	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getSuc() {
		return suc;
	}

	public void setSuc(String suc) {
		this.suc = suc;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List<Students> getStus() {
		return stus;
	}

	public void setStus(List<Students> stus) {
		this.stus = stus;
	}

	public String execute() throws Exception{
		HttpServletRequest request=ServletActionContext.getRequest();
		Teacher t=(Teacher)request.getSession().getAttribute("teacher");
		
		// 获得记录数
		int totalCount = new student().getCountModeStu(t, stuName);
		System.out.println(totalCount+"cccc");
		// 设置分页信息
		Page page = PageUtil.createPage(10, totalCount, currentPage);
		//取得该频道下的记录
		stus=new student().selectStudentByString(t, stuName, page);
        request.setAttribute("page",page);
		return SUCCESS;
		
	}

}
